using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.AnalyteDb;

public class FormNewIsotope : Form
{
	private IContainer components = null;

	private Label label1;

	private Label label2;

	private TextBox txtMass;

	private TextBox txtAbundance;

	private Button btnOK;

	private Button btnCancel;

	public double Mass { get; set; }

	public double Abundance { get; set; }

	public FormNewIsotope()
	{
		InitializeComponent();
	}

	private void btnOK_Click(object sender, EventArgs e)
	{
		try
		{
			Mass = Convert.ToDouble(txtMass.Text);
			try
			{
				Abundance = Convert.ToDouble(txtAbundance.Text);
			}
			catch
			{
				if (Abundance <= 0.0 || Abundance > 100.0)
				{
					MessageBox.Show(Lang.Txt("FormNewIsotope.AbundanceString.Text"), Lang.Txt("FormNewIsotope.MessageBox.Abundance.Text"), MessageBoxButtons.OK);
					return;
				}
			}
			base.DialogResult = DialogResult.OK;
		}
		catch
		{
			if (Mass < 1.0 || Mass > 300.0)
			{
				MessageBox.Show(Lang.Txt("FormNewIsotope.MassString.Text"), Lang.Txt("FormNewIsotope.MessageBox.Mass.Text"), MessageBoxButtons.OK);
			}
		}
	}

	private void btnCancel_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	private void FormNewIsotope_Load(object sender, EventArgs e)
	{
		Text = Lang.Txt("FormNewIsotope.Title.Text");
		label1.Text = Lang.Txt("FormNewIsotope.Mass.Text");
		label2.Text = Lang.Txt("FormNewIsotope.Abundance.Text");
		btnCancel.Text = Lang.Txt("FormNewIsotope.Button.OK.Text");
		btnOK.Text = Lang.Txt("FormNewIsotope.Button.Cancel.Text");
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.label2 = new System.Windows.Forms.Label();
		this.txtMass = new System.Windows.Forms.TextBox();
		this.txtAbundance = new System.Windows.Forms.TextBox();
		this.btnOK = new System.Windows.Forms.Button();
		this.btnCancel = new System.Windows.Forms.Button();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(57, 40);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(47, 12);
		this.label1.TabIndex = 0;
		this.label1.Text = "质量数:";
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(69, 70);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(35, 12);
		this.label2.TabIndex = 1;
		this.label2.Text = "丰度:";
		this.txtMass.Location = new System.Drawing.Point(110, 37);
		this.txtMass.Name = "txtMass";
		this.txtMass.Size = new System.Drawing.Size(85, 21);
		this.txtMass.TabIndex = 2;
		this.txtAbundance.Location = new System.Drawing.Point(110, 67);
		this.txtAbundance.Name = "txtAbundance";
		this.txtAbundance.Size = new System.Drawing.Size(85, 21);
		this.txtAbundance.TabIndex = 3;
		this.btnOK.Location = new System.Drawing.Point(42, 120);
		this.btnOK.Name = "btnOK";
		this.btnOK.Size = new System.Drawing.Size(75, 23);
		this.btnOK.TabIndex = 4;
		this.btnOK.Text = "确定";
		this.btnOK.UseVisualStyleBackColor = true;
		this.btnOK.Click += new System.EventHandler(btnOK_Click);
		this.btnCancel.Location = new System.Drawing.Point(143, 120);
		this.btnCancel.Name = "btnCancel";
		this.btnCancel.Size = new System.Drawing.Size(75, 23);
		this.btnCancel.TabIndex = 5;
		this.btnCancel.Text = "取消";
		this.btnCancel.UseVisualStyleBackColor = true;
		this.btnCancel.Click += new System.EventHandler(btnCancel_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(284, 166);
		base.Controls.Add(this.btnCancel);
		base.Controls.Add(this.btnOK);
		base.Controls.Add(this.txtAbundance);
		base.Controls.Add(this.txtMass);
		base.Controls.Add(this.label2);
		base.Controls.Add(this.label1);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "FormNewIsotope";
		this.Text = "添加新同位素";
		base.Load += new System.EventHandler(FormNewIsotope_Load);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
